#include <iostream>
#include <queue>
using namespace std;

typedef long long LL;
const int N = 1e4 + 10;

priority_queue<LL> fx;
queue<LL> f,fxx;
LL a[N];
int n,m;

int main(){
	cin >> n >> m;
	while(n--){
		int a,b,c;
		cin >> a >> b >> c;
		f.push(a);f.push(b);f.push(c);
	}
	while(f.size()){
		int a = f.front();f.pop();
		int b = f.front();f.pop();
		int c = f.front();f.pop();
		for(int i = 1;;i++){
			LL an = a*i*i + b * i + c;
			fx.push(an);
			if(fx.size() > m){
				LL t = fx.top();
				fx.pop();
				if(t == an){
					break;
				}
			}
		}
	}
	int sz = fx.size();
	for(int i = 0;i < sz;i++){
		a[i] = fx.top();
		fx.pop();
	}
	for(int i = sz - 1;i >= 0;i--){
		cout << a[i] << " ";
	}
	return 0;
} 
